<!--
* description: 包装样式查询
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamicButtons="tableButtons"
      :dynamicComponents="tableComponents"
      :dynamicApiConfig="apiConfig"
      :dynamicTableCols="tableCols"
      :dynamicFormFields="formField"
      :dynamicUnFormFields="unFormField"
      :dynamicIsShowSelect="true"
      :dynamicIsColumnDrop="true"
      :dynamicIsInitTable="true"
       :callbackObj="callbackObj"
     
    >
      <template slot="controlBtn" slot-scope="scope">
   

        <el-link
          type="primary"
          class="el-icon-document"
          :underline="false"
          @click="detail(scope.row)"
          title="明细"
          style="font-size:12px;"
          >明细</el-link
        >
        
        <el-link
          type="primary"
          class="el-icon-download"
          :underline="false"
          @click="fileDownload(scope.row)"
          title="附件下载"
          style="font-size:12px;"
          >附件下载</el-link
        >
      </template>
    </one-table-template>
    <fileDownload
      v-if="isFileDownloadShow"
      @fileDownloadlose="fileDownloadlose"
      :isFileDownloadShow="isFileDownloadShow"
      :talbeRowData="talbeRowData"
    />
    <detail
      v-if="isShow"
      :talbeRowData="talbeRowData"
      @detailClose="detailClose"
      :isShow="isShow"
    />
  </div>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import { wmsApis } from "@/api/wms/packingMaterialStyle/api";
import OneTableTemplate from "@/components/wms/templates/oneTable";
import request from "@/utils/request";
import store from "@/store";
export default {
  name: "packingMaterialQuery",
  // 组件混入对象
  mixins: [oneTableWithViewTemplateMixins],
  components: {
    OneTableTemplate,
    fileDownload: () => import("../common/fileDownload"),
    detail: () => import("./detail")
  },
  watch: {
    $route(val) {
      if (
        this.formField.pageId !== "" &&
        this.$route.query.pageId !== undefined &&
        this.$route.query.pageId !== this.formField.pageId
      ) {
        this.formField.pageId = this.$route.query.pageId;
        this.formField.pageName = this.$route.query.pageName;
        this.queryTable();
      }
    }
  },
  created() {
    if (this.$route.query != null) {
      // 判断传入query参数，初始化数据
      if (this.$route.query.pageId != null && this.$route.query.pageId !== "") {
        this.formField.pageId = this.$route.query.pageId;
        this.formField.pageName = this.$route.query.pageName;
      }
    }
  },
  data() {
    return {
      // 网格查询API配置对象
      apiConfig: wmsApis.materialsStyle,
      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey1",
          type: "primary",
          size: "small",
          clickEvent: () => this.queryTable(),
          name: "search",
          position: "right",
          text: "查询" //"查询"
        },
        // {
        //   compKey: "btnKey2",
        //   // type: "primary",
        //   size: "small",
        //   clickEvent: () => this.submissionUp(),
        //   name: "",
        //   position: "right",
        //   text: "禁用"
        // },

        {
          compKey: "btnKey3",
          type: "",
          size: "small",
          name: "reset",
          position: "right",
          clickEvent: () => this.reset(),
          text: "重置"
        }
      ],
      // 动态组件-查询条件
      tableComponents: [
        {
          compKey: "compKey1",
          labelName: "包装样式编号",
          codeField: "STYLE_CODE",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey2",
          labelName: "备件编号",
          codeField: "PART_CODE",
          component: () => import("@/components/wms/commonInput"),
          type: "inputText",
          isMust: true
        },
        {
          compKey: "compKey3",
          labelName: "审核状态",
          codeField: "STATUS",
          component: () => import("@/components/wms/dropdownList/dropdownList"),
          type: "dropdownList",
          isMust: true,
          isMul: false,
          options: [
            { label: "启用", value: "02" },
            { label: "历史记录", value: "04" }
          ]
        }
      ],
      // 动态生成网格列
      tableCols: [
        {
          prop: "controlBtn",
          label: "操作",
          codeField: "controlBtn",
          width: 200,
          align: "center",
          isSlot: true
        },
        {
          prop: "STYLE_CODE",
          label: "包装样式编号",
          align: "center"
        },
        {
          prop: "PART_CODE",
          label: "备件编号",
          align: "center"
        },
        {
          prop: "PART_NAME",
          label: "备件名称",
          align: "center"
        },
        {
          prop: "PART_NUM",
          label: "包装数量",
          align: "center"
        },
        {
          prop: "REMARK",
          label: "备注",
          align: "center"
        },
        {
          prop: "CREATED_DATE",
          label: "创建日期",
          align: "center"
        },
        {
          prop: "CREATOR",
          label: "创建人",
          align: "center"
        },
        {
          prop: "STATUS_NAME",
          label: "审核状态",
          align: "center"
        },
        {
          prop: "MESSAGE",
          label: "驳回原因",
          align: "center"
        }
      ],
      //表单查询数据
      formField: {
        STYLE_CODE: "",
        PART_CODE: "",
        STATUS: "",
        SELECTION_STATE: "2"
      },
      unFormField: {},
      // 控制附件下载弹窗
      isFileDownloadShow: false,
      // 行数据
      talbeRowData: {},
      // 控制明细弹窗
      isShow: false,
       // 回调函数
      callbackObj: {
        //  当选择项发生变化时会触发该事件
        onCheckSelectChange: selection => {
          this.checkTableList = selection;
        }
      },
       // 选中的表格数据
      checkTableList: [],
    };
  },
  methods: {
  //  submissionUp() {
  //    console.log(this.checkTableList);
  //     if (this.checkTableList.length > 0) {
  //       this.$confirm("确定要禁用吗？", "提示", {
  //         confirmButtonText: "确定",
  //         cancelButtonText: "取消"
  //       })
  //         .then(() => {
  //           request({
  //             url: "/mp/wm/vl/warehouse/materialsStyle/disableMaterials.do",
  //             method: "post",
  //             data: {
  //               IDS: this.checkTableList
  //             }
  //           }).then(res => {
  //             if (res.result === "1") {
  //               this.queryTable();
  //               this.$message({
  //                 message: "禁用成功",
  //                 type: "success"
  //               });
  //             } else {
  //               this.$message({
  //                 message: res.debugMsg ? res.debugMsg : res.msg,
  //                 type: "warn"
  //               });
  //             }
  //           });
  //         })
  //         .catch(err => {
  //           console.info(err);
  //         });
  //     } else {
  //       this.$message({
  //         message: "请选择一条数据"
  //       });
  //     }
  //   },
  

    detail(row) {
      this.talbeRowData = row;
      this.isShow = true;
    },
    detailClose() {
      this.isShow = false;
    },
    fileDownload(row) {
      this.talbeRowData = row;
      this.isFileDownloadShow = true;
    },
    fileDownloadlose() {
      this.isFileDownloadShow = false;
    }
  }
};
</script>
